package com.efesco.service.compensation;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.efesco.common.CommUtil;

/**
 * V_auditing_listViewModel
 */
public class V_auditing_listViewModel extends DefaultViewModel {
  public void init(int state)
      throws Exception {

    super.init(state);
  }

  protected void initDatasets()
      throws Exception {
    super.initDatasets();
    // Add your code here
  }

  protected void initControls()
      throws Exception {
    super.initControls();
	 // getDataset("dataset_select").getField("FOREIGN_ENTERPRISE_ID").setDefaultValue("2");
	  CommUtil.setTrueId(getDataset("dataset_select"));
  }

  protected void doUpdateData(ParameterSet parameters)
  throws Exception {
	  DBStatement dbs=new DBStatement();

	  Dataset ds=getDataset("sqldataset_auditing_list");
	  ds.moveFirst();
	  while(!ds.isLast()){
		  //if(ds.getRecordState() == Record.STATE_MODIFIED){
		  if(ds.getBoolean("select")){
				 dbs.setSql("delete from s_verify_result where medical_bill_id="+ds.getString("MEDICAL_BILL_ID"));
				 dbs.execute();
				 dbs.setSql("insert into s_verify_result(MEDICAL_BILL_ID,AMOUNT,VERIFY_DATE,DISEASE_REASON,REMARK,VERIFY_STAFF_ID,VERIFY_TYPE)values(" +
						 ds.getString("MEDICAL_BILL_ID")+",'"+ds.getString("VRAMOUNT")+"',sysdate,'"+ds.getString("DISEASE_REASON")
						 +"','"+ds.getString("REMARK")+ "','"+CommUtil.getOperatetId()+"','"+parameters.getValue("type")+"')");
				 dbs.execute();
			  }

		  ds.moveNext();
	  }
	  
	  
	  dbs.close();
  }
  
  
}
